/**
 * Copyright 2011-2011 - Members of the Chaupal Community
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package net.chaupal.Impl.Callback;

import java.util.concurrent.Callable;

/**
 * Event indicating that a task has been proceeded.
 * 
 * @param <V> the result type of method <tt>call</tt> of the callable
 */
public interface CallbackEvent<V> {
   
    /**
     * Provides the corresponding event callable.
     * 
     * @return the corresponding event callable
     */
    Callable<V> getSourceCallable();
    
    /**
     * Provides the callable result or <tt>null</tt> if none is available.
     * 
     * @return the callable result or <tt>null</tt> if none is available
     */
    V getResult();
    
    /**
     * Returns <tt>true</tt> if this task was not finished before wait time-out.
     *
     * @return <tt>true</tt> if this task was not finished before wait time-out
     */
    boolean timedOut();
    
    /**
     * Returns <tt>true</tt> if the computation threw an exception.
     *
     * @return <tt>true</tt> if the computation threw an exception
     */
    boolean hasExecutionException();
    
    /**
     * Returns <tt>true</tt> if the computation was interrupted/cancelled.
     *
     * @return <tt>true</tt> if the computation was interrupted/cancelled
     */
    boolean wasCancelled();

    /**
     * Provides the exception if the computation threw an exception or
     * <tt>null</tt> otherwise.
     * 
     * @return the exception if the computation threw an exception or
     * <tt>null</tt> otherwise
     */
    Exception getExecutionException();
    
}
